export const sendChatMessage = async (data) => {
    const formData = new FormData();
    formData.append('prompt', data.prompt);

    // 使用fetch API实现流式读取
    const response = await fetch('/api/ai/chat/ts', {
        method: 'POST',
        body: data instanceof FormData ? data :
            new URLSearchParams({prompt: data})
    })

    if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`)
    }

    return response.body.getReader()
}